package com.shuqi.common.utils;

import android.app.Activity;
import android.app.Dialog;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.shuqi.activity.viewport.BottomDialog;
import com.shuqi.controller.R;

/**
 * 
 * Dialog工具类
 * 
 * @author li.li
 * @date 2014-06-15
 */
public class DialogUtils {

    /**
     * 显示底部对话框
     * @param act
     * @param title
     * @param content
     * @param eMsg
     * @param Msg
     * @param eListener
     * @param cListener
     */
    public static Dialog showDialogConfirmBottom(Activity act, String title, String content, String eMsg,
            String cMsg, OnClickListener eListener, OnClickListener cListener) {

        View view = act.getLayoutInflater().inflate(R.layout.view_dialog_common_confirm, null);

        TextView dialogTitle = (TextView) view.findViewById(R.id.view_dialog_common_confirm_title);
        TextView dialogContent =
                (TextView) view.findViewById(R.id.view_dialog_common_confirm_content);
        TextView dialogCancle = (TextView)view.findViewById(R.id.view_dialog_common_confirm_button_cacel_msg);
        TextView dialogConfirm = (TextView)view.findViewById(R.id.view_dialog_common_confirm_button_ensure_msg);

        dialogTitle.setText(title);
        dialogContent.setText(content);
        dialogCancle.setText(cMsg);
        dialogConfirm.setText(eMsg);

        Dialog dialog = new BottomDialog(act, view);
        dialogConfirm.setOnClickListener(eListener);
        dialogCancle.setOnClickListener(cListener);

        dialog.show();
        
        return dialog;
    }
    
    /**
     * 关闭对话框 
     * @param dialog
     */
    public static void dismissDialog(Dialog dialog){
        if (dialog != null && dialog.isShowing()) {
            dialog.dismiss();
        }
    }

}
